package warbots.entities.artifacts;


import java.awt.Point;

import warbots.entities.units.Unit;
import warbots.gameplay.Map;


/**
 * @author Ido Adler.
 */
public class ArtifactFactory
{
    public static Artifact newInstance(final Unit user, final String name)
    {
        String[] args = name.split(":");
        if (args[0].equals("SHOOT"))
        {
            if (args.length > 2)
                return new HammerArtifact(user, "Hammer:" + args[1], Integer.parseInt(args[2]));
            else
                return new HammerArtifact(user, "Hammer:" + args[1], Integer.parseInt(args[1]));
        }
        
        return new Artifact(user, name, 0, false)
        {
            @Override
            public void execute(final Map world, final Point target)
            {
                System.out.println(_parent.getName() + ":" + getName() + "->"
                    + target.toString());
            }
        };
    }
}
